<form action="<?php echo LinkGen::getInstance(LinkGen::PRODUCT)->link($product['id'], array('action' => 'submitComment'))  ?>" method="post">
<?php echo $commentsForm->renderHiddenFields(true) ?>
<div class="comment">
	<h1><?php echo __('uus arvamus') ?></h1>

	<div id="comment_flashes">

	</div>

	<div class="area">
		<div class="arealeft"><img src="/enermaatik/img/arealeft.png" width="10" height="95" alt=""/></div>
		<div class="areacenter">
				<?php $class = 'areatext'?>
				<?php echo $commentsForm['message']->render(array('class' => $class))  ?>
		</div>

		<div class="arearight"><img src="/enermaatik/img/arearight.png" width="10" height="95" alt=""/></div>
		<div class="clear"></div>
	</div>
	<div class="commentname">
			<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
			<div class="formcenter">
				<?php $class = 'comname'?>
				<?php echo $commentsForm['name']->render(array('class' => $class , 'title'=> __('Name') ) )  ?>
			</div>
			<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
		<div class="clear"></div>
	</div>
	<div class="rating_set" style="padding:10px">
		<input class="star" type="radio" name="<?php echo $commentsForm['rating']->renderName() ?>" value="1"/>
		<input class="star" type="radio" name="<?php echo $commentsForm['rating']->renderName() ?>" value="2"/>
		<input class="star" type="radio" name="<?php echo $commentsForm['rating']->renderName() ?>" value="3"/>
		<input class="star" type="radio" name="<?php echo $commentsForm['rating']->renderName() ?>" value="4"/>
		<input class="star" type="radio" name="<?php echo $commentsForm['rating']->renderName() ?>" value="5"/>
	</div>
	<div class="cod">
		<div class="codleft">
			<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
			<div class="formcenter">
				<?php $class = 'comcode'?>
				<?php echo $commentsForm['captcha']->render(array('class' => $class   ) )  ?>
			</div>
			<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
		</div>
		<div class="codright">
			<div id="captcha_refresh" class="refresh"><img src="/enermaatik/img/refresh.png" width="26" height="36" alt=""/></div>
			<div class="codimg"><img id="captcha_image" src="<?php echo url_for('sf_captchagd', array('r' => time() ) ) ?>" width="113" height="36" alt=""/></div>
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>

	<div class="button" id="submitcomment">
		<div class="buttonleft"><img src="/enermaatik/img/rbleft.png" width="8" height="26" alt=""/></div>
		<div class="buttoncenter">
			<a href="#"><?php echo __('saada arvamus') ?></a>
		</div>
		<div class="buttonright"><img src="/enermaatik/img/rbr.png" width="8" height="26" alt=""/></div>
		<div class="clear"></div>
	</div>
</div>
</form>
<script type="text/javascript">

$('input, textarea').clearInputDescription();

$('#submitcomment').click(function(e){
	e.preventDefault();
	var button = $(this);
	var form = $(this).parents('form');

	button.hide();
	$('#comment_flashes').html('');
	
	$.post(form.attr('action'),form.serialize(),function(data){
		if(data.status == 200){
			$('#comment_flashes').html(data.messages[0]);
		}else{
			for (var i in data.messages ){
				$('#comment_flashes').html( $('#comment_flashes').html() + "<br />" +  data.messages[i]);
			}
			button.show();
		}
	},'json');

	return false;
});


$(function(){
	$('.rating_set :radio.star').rating();
});


$('#captcha_refresh').click(function(e){
	e.preventDefault();
	$('#captcha_image').attr('src','<?php echo url_for('sf_captchagd', array('reload' => 1 ) ) ?>' + '&r=' + Math.random());
	return false;
});

</script>